# main方法
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from lane_detection import *


# 写入图象
image = mpimg.imread('test_images/solidWhiteRight.jpg')
initial_img = mpimg.imread('test_images/solidWhiteRight.jpg')
# 统计数据并且绘图
print('This image is:', type(image), 'with dimensions:', image.shape)
# 灰度处理
gray = grayscale(image)

# 高斯平滑/模糊
kernel_size = 5
blur_gray = gaussian_blur(gray, kernel_size)

# 定义Canny算子参数
low_threshold = 50
high_threshold = 150
adges = canny(blur_gray, low_threshold, high_threshold)

# 定义ROI
imshape = adges.shape
vertices = np.array([[(0,imshape[0]),(450, 290), (490, 290), 
					  (imshape[1],imshape[0])]], dtype=np.int32)
masked_image = region_of_interest(adges, vertices)
plt.imshow(masked_image)
plt.show()


# 进行霍夫变换
rho = 2
theta = np.pi / 180
threshold = 15
min_line_length = 100
max_line_gap = 20
line_img = hough_lines(masked_image, rho, theta, threshold, min_line_length, max_line_gap)

combo = weighted_img(line_img, initial_img, α=0.8, β=1., γ=0.)
##plt.imshow(combo)
##plt.show()